<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/5/21 0021
  Time: 10:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="bp" value="${pageContext.request.contextPath}"></c:set>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:useBean id="timestamp" class="java.util.Date"/>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div>
    <form class="form-horizontal" role="form">
        <div class="form-group">
            <label for="username" class="col-sm-2 control-label">名字</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="username" placeholder="请输入名字">
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">密码</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="password" placeholder="请输入密码">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" onclick="add()" class="btn btn-default">注册</button>
            </div>
        </div>
    </form>
</div>
</body>

<script type="application/javascript">
    function add() {
        var username =  $("#username").val()
        var password = $("#password").val()

        $.ajax({
            type:"post",
            url:"${bp}/user/insert",
            data:{"username":username,"password":password},
            success : function (msg) {
                if(msg == 1){
                    alert("添加成功")
                    window.location = "login.jsp"
                }else{
                    alert("添加失败")
                }
            }
        })



    }






</script>

<script src="${bp}/static/assets/js/jquery-3.2.1.min.js"></script>
<!-- Bootstrap Js -->
<script src="${bp}/static/assets/js/bootstrap.min.js"></script>
<!-- Metis Menu Js -->
<script src="${bp}/static/assets/js/jquery.metisMenu.js"></script>
<!-- Morris Chart Js -->
<script src="${bp}/static/assets/js/morris/raphael-2.1.0.min.js"></script>
<script src="${bp}/static/assets/js/morris/morris.js"></script>
<script src="${bp}/static/assets/js/easypiechart.js"></script>
<script src="${bp}/static/assets/js/easypiechart-data.js"></script>
<script src="${bp}/static/assets/js/Lightweight-Chart/jquery.chart.js"></script>
<!-- Custom Js -->
<script src="${bp}/static/assets/js/custom-scripts.js"></script>

</html>
